package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.pojo.UserEntity;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xukang
 * @date 2021-09-10 15:18
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    //注册
    @PostMapping("register")
    public Result register(@RequestParam("username") String username,
                           @RequestParam("account") String account,
                           @RequestParam("realname") String realname,
                           @RequestParam("age") Integer age) {
        return userService.register(username, account, realname, age);
    }
    @PostMapping("update/{id}")
    public Result updateById(@PathVariable("id")Long id,@RequestBody UserEntity userEntity) {
        return userService.updateById(id, userEntity);
    }
    @PostMapping("getByContion")
    public Result getAll(@RequestBody UserEntity userEntity) {
        return userService.getByContion( userEntity);
    }
}
